Interval<T>

Describes an interval of time to be used in time-based calculations. Provides methods to calculate rates and frequencies based on the interval value and type.

Syntax

public class Interval<T> where T : IComparable<T>, IConvertible

Inheritance

Constructors

Interval

public Interval()
Creates a new instance of the class.

Interval

public Interval(T value, IntervalType type)
Creates a new instance of the class.

Parameters

  • value T: The duration of the interval.
  • type IntervalType: The base unit that describes what the quantity of this Interval references.

Properties

Type

public IntervalType Type { get; set; }
The base unit that describes what the quantity of this Interval references.

Returns

IntervalType

Value

[DataType(DataType.Duration)]
public T Value { get; set; }
The duration of the Interval.

Returns

T

Methods

PerDay

public virtual decimal PerDay()
Given this instance, calculates how many occurrences will happen per day.

Returns

decimal The number of occurrences per day as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

PerDay

public virtual decimal PerDay(decimal quantity)
Given this instance and a quantity, calculates the total output per day.

Parameters

  • quantity decimal: The quantity to multiply by the interval frequency.

Returns

decimal The total output per day as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

PerHour

public virtual decimal PerHour()
Given this instance, calculates how many occurrences will happen per hour.

Returns

decimal The number of occurrences per hour as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

PerHour

public virtual decimal PerHour(decimal quantity)
Given this instance and a quantity, calculates the total output per hour.

Parameters

  • quantity decimal: The quantity to multiply by the interval frequency.

Returns

decimal The total output per hour as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

PerMinute

public virtual decimal PerMinute()
Given this instance, calculates how many occurrences will happen per minute.

Returns

decimal The number of occurrences per minute as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

PerMinute

public virtual decimal PerMinute(decimal quantity)
Given this instance and a quantity, calculates the total output per minute.

Parameters

  • quantity decimal: The quantity to multiply by the interval frequency.

Returns

decimal The total output per minute as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

PerMonth

public virtual decimal PerMonth()
Given this instance, calculates how many occurrences will happen per month.

Returns

decimal The number of occurrences per month as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

PerMonth

public virtual decimal PerMonth(decimal quantity)
Given this instance and a quantity, calculates the total output per month.

Parameters

  • quantity decimal: The quantity to multiply by the interval frequency.

Returns

decimal The total output per month as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

PerWeek

public virtual decimal PerWeek()
Given this instance, calculates how many occurrences will happen per week.

Returns

decimal The number of occurrences per week as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

PerWeek

public virtual decimal PerWeek(decimal quantity)
Given this instance and a quantity, calculates the total output per week.

Parameters

  • quantity decimal: The quantity to multiply by the interval frequency.

Returns

decimal The total output per week as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

PerYear

public virtual decimal PerYear()
Given this instance, calculates how many occurrences will happen per year.

Returns

decimal The number of occurrences per year as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

PerYear

public virtual decimal PerYear(decimal quantity)
Given this instance and a quantity, calculates the total output per year.

Parameters

  • quantity decimal: The quantity to multiply by the interval frequency.

Returns

decimal The total output per year as a decimal value.

Exceptions

  • [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception): Thrown if T is not convertible to a .

ToString

public override string ToString()
Returns a string that represents the current object.

Returns

string A string that represents the current object.